function time(){
	return new Date().getTime();
}


$("#addOtherActivity").live( "click", function() {
	var intCount = $(".schedule").size();
	++intCount;
	
	var strFieldName = "data[Schedule]["+ intCount +"]";
	var lastSchedule = $( ".schedule:last" );
	var newSchedule = lastSchedule.clone();
	
	newSchedule.find( ".removeSchedule:first" ).show();
	newSchedule.find( ".deleteSchedule:first" ).remove();
	
	
	newSchedule.find( ".scheduleName:first" ).attr( "name", strFieldName + "[name]"  ).val('');
	newSchedule.find( ".scheduleDescription:first" ).attr( "name", strFieldName + "[description]"  ).val('');
	
	newSchedule.find( ".scheduleMonday:first" ).attr( "name", strFieldName + "[monday]"  ).removeAttr('checked').attr('id', time());
	newSchedule.find( ".scheduleMonday:first" ).prev().attr( "name", strFieldName + "[monday]"  );
	
	newSchedule.find( ".scheduleTuesday:first" ).attr( "name", strFieldName + "[tuesday]"  ).removeAttr('checked').attr('id', time());
	newSchedule.find( ".scheduleTuesday:first" ).prev().attr( "name", strFieldName + "[tuesday]"  );
	
	newSchedule.find( ".scheduleWednesday:first" ).attr( "name", strFieldName + "[wednesday]"  ).removeAttr('checked').attr('id', time());
	newSchedule.find( ".scheduleWednesday:first" ).prev().attr( "name", strFieldName + "[wednesday]"  );
	
	newSchedule.find( ".scheduleThursday:first" ).attr( "name", strFieldName + "[thursday]"  ).removeAttr('checked').attr('id', time());
	newSchedule.find( ".scheduleThursday:first" ).prev().attr( "name", strFieldName + "[thursday]"  );
	
	newSchedule.find( ".scheduleFriday:first" ).attr( "name", strFieldName + "[friday]"  ).removeAttr('checked').attr('id', time());
	newSchedule.find( ".scheduleFriday:first" ).prev().attr( "name", strFieldName + "[friday]"  );
	
	newSchedule.find( ".scheduleSaturday:first" ).attr( "name", strFieldName + "[saturday]"  ).removeAttr('checked').attr('id', time());
	newSchedule.find( ".scheduleSaturday:first" ).prev().attr( "name", strFieldName + "[saturday]"  );
	
	newSchedule.find( ".scheduleSunday:first" ).attr( "name", strFieldName + "[sunday]"  ).removeAttr('checked').attr('id', time());
	newSchedule.find( ".scheduleSunday:first" ).prev().attr( "name", strFieldName + "[sunday]"  );
	
	newSchedule.find( ".scheduleStartTimeHour:first" ).attr( "name", strFieldName + "[start_time_hour]"  ).val(11);
	newSchedule.find( ".scheduleStartTimeMinute:first" ).attr( "name", strFieldName + "[start_time_minute]"  ).val(0);
	newSchedule.find( ".scheduleEndTimeHour:first" ).attr( "name", strFieldName + "[end_time_hour]"  ).val(11);
	newSchedule.find( ".scheduleEndTimeMinute:first" ).attr( "name", strFieldName + "[end_time_minute]"  ).val(0);
	
	newSchedule.find( ".scheduleIsBussy:first" ).attr( "name", strFieldName + "[is_bussy]"  ).attr('checked', 'checked');
	newSchedule.find( ".scheduleIsBussy:first" ).prev().attr( "name", strFieldName + "[is_bussy]"  );

	lastSchedule.after( newSchedule );
	
	$(".daySelector").find("label").attr( "for", "" );
	
	return false;
});

$( ".removeSchedule" ).live( "click", function() {
	$(this).parents( ".schedule:first" ).fadeOut( "fast", function() {
		$(this).remove();
	});
	return false;
});